package com.fz.controller;

import com.fz.mapper.BaoMingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * Created by webrx on 2018-06-27.
 */
@Controller
public class IndexController {
    @Autowired
    protected BaoMingMapper bmdao;
    @RequestMapping
    public ModelAndView index(){
        ModelAndView mv = new ModelAndView("index");
        mv.addObject("bm",bmdao.query());
        return mv;
    }
    @RequestMapping("/info") @ResponseBody
    public String info(HttpServletRequest req){
        Enumeration<String> e = req.getHeaderNames();
        while(e.hasMoreElements()){
            String key = e.nextElement();
            System.out.printf("%s = %s\n",key,req.getHeader(key));
        }
        System.out.println();
        String i = System.getProperty("os.name");
        return i;
    }
}
